local app = require 'app'
local game = app.game.running

local ready = game.ui.element()

ready.store_watchers = 
{
    room = 
    {
        ['$'] = function(self) end,

        ['更新准备状态'] = function(self, store, state, player)
            if game.kbe.player() ~= player then
                return
            end

            if player.is_ready then
                self:hide()
            else
                self:show()
            end
        end
    }
}

function ready:ctor()
    self.res = 'club.threecard.doudizhu/ui/ingame.b:ready'
end

function ready:on_injected(bind)
    bind('button.click', self.ready_btn, self.ready_ivk)
    game.utility.button_style.highlight_scale(self.ready_btn)
end

function ready:ready_ivk()
    game.kbe.player():ready(true)
end

function ready:clear_scene()
    self:hide()
end

return ready